dojo.addOnLoad(function () {
	//-------------------------------------------------------
	function WebFetion(name,password){
		this.name = name;
		this.password = password;
	};
	WebFetion.prototype = {
		login:function(img_code,status){
			
		}
		get_personal_info:function(){
			
		},
		get_contact_list:function(){
			
		},
		keep_alive:function(){
			
		},
		send_msg:function(msg,isSMS){
			
		},
		on_receive_msg:function(sender,msg){
			
		},
		on_status_change:function(){
			
		},
		update_status:function(contact,status){
			
		},
		get:function(url,on_load){
			dojo.xhrGet({
				url:url,
				load:on_load
			});
		},
		post:function(form_id,on_load){
			dojo.xhrPost({
				form:form_id,
				load:on_load
			});
		}
	};
	//----------------------------------------------------------
	
   function login(e) {
      dojo.stopEvent(e);
      dojo.xhrPost({
         form: "login_form",
         load: function (data) {
            data = dojo.fromJson('' + data + '');
            console.log(data);
            if (data.rc === 200) {
               dojo.xhrGet({
                  url: '/get_personal_info',
                  load: function () {
                     console.info(data);
                     if (data.rc === 200) {
                        dojo.xhrGet({
                           url: '/get_contact_list',
                           load: function () {
                              console.log(data);
                              if (data.rc === 200) {
                                 dojo.xhrGet({
                                    url: '/keep_alive',
                                    load: function () {
                                       console.log(data);

                                    }
                                 });
                              }
                           }
                        });
                     }
                  }
               });
            }
         }
      });

   }

   dojo.connect(dojo.byId('login'), 'click', login);
   dojo.connect(dojo.byId('login_form'), 'submit', login);

});
